//
//  LGRecordHospitalCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/6/8.
//

#import "LGRecordHospitalCell.h"

#define lineHeight       viewPix(30)
#define contentWidth     (Screen_W-viewPix(64)-80)

@interface LGRecordHospitalCell()

/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UIButton *titleBtn;
/**   */
@property (nonatomic , strong)UILabel *enterTitle;
/**   */
@property (nonatomic , strong)UILabel *enterContent;
/**   */
@property (nonatomic , strong)UILabel *leaveTitle;
/**   */
@property (nonatomic , strong)UILabel *leaveContent;
/**   */
@property (nonatomic , strong)UILabel *numberTitle;
/**   */
@property (nonatomic , strong)UILabel *numberContent;

@end

@implementation LGRecordHospitalCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    self.enterContent.text = LGNSString(dataDic[@"hospitalized_time"]);
    self.leaveContent.text = LGNSString(dataDic[@"leave_time"]);
    self.numberContent.text = [NSString stringWithFormat:@"%@ 天",dataDic[@"hospital_day"]];
}


-(void)createSubView{
    self.contentView.backgroundColor = [UIColor colorWithString:@"#F9F9F9"];
    [self.contentView addSubview:self.baseView];
    [self.baseView addSubview:self.titleBtn];
    [self.baseView addSubview:self.enterTitle];
    [self.baseView addSubview:self.enterContent];
    [self.baseView addSubview:self.leaveTitle];
    [self.baseView addSubview:self.leaveContent];
    [self.baseView addSubview:self.numberTitle];
    [self.baseView addSubview:self.numberContent];
    [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(viewPix(8));
        make.bottom.equalTo(self.contentView).offset(-viewPix(8));
        make.left.equalTo(self.contentView).offset(viewPix(16));
        make.right.equalTo(self.contentView).offset(-viewPix(16));
        make.height.equalTo(@(viewPix(162)));
    }];
}

-(UIView *)baseView{
    if(!_baseView){
        _baseView = [UIView shadowViewWithColor:@"#B3C5D9" offset:CGSizeMake(0, 2) opacity:0.1 radius:15];
        _baseView.backgroundColor = [UIColor whiteColor];
    }
    return _baseView;
}

-(UIButton *)titleBtn{
    if(!_titleBtn){
        _titleBtn = [UIButton buttonWithTitle:@"报告信息" titleFont:LGFontWeight(16, UIFontWeightMedium) textColor:@"#1F6CC6" imageName:@""];
        [_titleBtn setBackgroundImage:[UIImage imageNamed:@"就诊检查-蓝色"] forState:UIControlStateNormal];
        _titleBtn.frame = CGRectMake(0, viewPix(20), 112, 27);
        _titleBtn.userInteractionEnabled = NO;
    }
    return _titleBtn;
}

-(UILabel *)enterTitle{
    if(!_enterTitle){
        _enterTitle = [UILabel lableWithText:@"入院时间" colorString:@"#666666" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
        _enterTitle.frame = CGRectMake(viewPix(16), viewPix(55), 70, lineHeight);
    }
    return _enterTitle;
}

-(UILabel *)enterContent{
    if(!_enterContent){
        _enterContent = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(16, UIFontWeightMedium) textAlignment:NSTextAlignmentRight lines:1];
        _enterContent.frame = CGRectMake(viewPix(16)+80, kMinY(self.enterTitle.frame), contentWidth, lineHeight);
    }
    return _enterContent;
}

-(UILabel *)leaveTitle{
    if(!_leaveTitle){
        _leaveTitle = [UILabel lableWithText:@"出院时间" colorString:@"#666666" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
        _leaveTitle.frame = CGRectMake(viewPix(16), kMaxY(self.enterTitle.frame), 70, lineHeight);
    }
    return _leaveTitle;
}

-(UILabel *)leaveContent{
    if(!_leaveContent){
        _leaveContent = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(16, UIFontWeightMedium) textAlignment:NSTextAlignmentRight lines:1];
        _leaveContent.frame = CGRectMake(viewPix(16)+80, kMinY(self.leaveTitle.frame), contentWidth, lineHeight);
    }
    return _leaveContent;
}

-(UILabel *)numberTitle{
    if(!_numberTitle){
        _numberTitle = [UILabel lableWithText:@"住院天数" colorString:@"#666666" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
        _numberTitle.frame = CGRectMake(viewPix(16), kMaxY(self.leaveTitle.frame), 70, lineHeight);
    }
    return _numberTitle;
}

-(UILabel *)numberContent{
    if(!_numberContent){
        _numberContent = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(16, UIFontWeightMedium) textAlignment:NSTextAlignmentRight lines:1];
        _numberContent.frame = CGRectMake(viewPix(16)+80, kMinY(self.numberTitle.frame), contentWidth, lineHeight);
    }
    return _numberContent;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
